﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Microsoft.SolverFoundation.Services;

namespace Flux_Balance_Analysis
{
    /// <summary>
    /// Logica di interazione per ConstraintControl.xaml
    /// </summary>
    public partial class ConstraintControl : UserControl
    {
        #region Events
        public event EventHandler DelectionRequired;
        public event EventHandler ConstraintChanged;
        #endregion

        #region Properties
        public string ConstraintName { get; set; }
        public string ConstraintExpression { get { return this.txtConstraint.Text; } set { this.txtConstraint.Text = value; } }
        public bool ConstraintEnabled { get { return this.chkIsEnabled.IsChecked.HasValue && this.chkIsEnabled.IsChecked.Value; } set { this.chkIsEnabled.IsChecked = value; } } 
        #endregion

        #region Fields
        #endregion

        #region Methods
        public ConstraintControl()
        {
            InitializeComponent();
        }

        private void cmdDelete_Click(object sender, RoutedEventArgs e)
        {
            if (DelectionRequired != null)
                DelectionRequired(this, null);
            if (ConstraintChanged != null)
                ConstraintChanged(this, null);
        }
        private void txtConstraint_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (ConstraintChanged != null)
                ConstraintChanged(this, null);
        }

        private void chkIsEnabled_Checked(object sender, RoutedEventArgs e)
        {
            if (ConstraintChanged != null)
                ConstraintChanged(this, null);
        }
        #endregion
    }
}
